<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/10/26 0026
 * Time: 下午 8:45
 */

header('Content-type:textml;charset=utf-8');
require './public——function.php';
dbInit();
if (!empty($_POST)){
    $_fields = array('e_name','e_dept','date_of_birth','date_of_entry');
    $value = array();
    foreach ($_fields as $k => $v){
        $data = isset($_POST[$v]) ? $_POST[$v] : '';
        if ($data=='')die($v.'字段不能为空');
        $data = safeHandle($data);
        $_fields[$k] = "`$v`";
        $values[] = "'$data'";
    }
    $_fields = implode(',',$_fields);
    $_values = implode(',',$_values);
    $sql = "insert into `emp_info` ($_fields) VALUES ($values)";
    if ($res = query($sql)){
        header('Location: ./showList.php');
        die;
    }else{
        die('员工添加失败！');
    }
}
define('APP','itcast');
require './add_html.php';
